package com.xuan.task.Mapper;

import com.xuan.task.domain.WordAndCount;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


@Mapper
public interface WordPracticeHistoryMapper {

    @Select( "select word,type,count(*) wordCount from word_practice_history where user_id =#{userId} and result =1 and type in (2,3,5)" +
            "        and word in (SELECT DISTINCT word FROM resource_word_relation r" +
            "        join vocabulary_resource_library vr on r.vocabulary_resource_num = vr.resource_library_num" +
            "        WHERE vocabulary_resource_num in (select resource_library_num  from  electronic_library_relation where book_num =#{bookNum})" +
            "        and word in (select word from vocabulary where audio_path!='' and is_delete=0 ))" +
            "        group by word,type" )
    List<WordAndCount> getWordAndCountByUserIdAndBookNum(@Param( "userId" ) String userId,@Param( "bookNum" )  String bookNum);
}
